//
//  NSMutableAttributedString+HHExtension.m
//  Smart
//
//  Created by Hayder on 2022/12/25.
//

#import "NSMutableAttributedString+HHExtension.h"

@implementation NSMutableAttributedString (HHExtension)

+ (NSMutableAttributedString *)createAttributeWithText:(NSString *)contentText textFont:(UIFont *)font textColor:(UIColor *)textColor hightlightText:(NSString *)hightText hightlightFont:(UIFont *)hightlightFont hightlightColor:(UIColor *)hightlightColor alignment:(NSTextAlignment)alignment
{
    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:contentText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = 5; // 设置行间距
    paragraphStyle.alignment = alignment;
    [attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrString.length)];
    [attrString addAttribute:NSForegroundColorAttributeName value:textColor range:NSMakeRange(0, contentText.length)];
    [attrString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0,contentText.length)];
    NSRange range = [contentText rangeOfString:hightText];
    [attrString addAttribute:NSForegroundColorAttributeName value:hightlightColor range:range];
    [attrString addAttribute:NSFontAttributeName value:hightlightFont range:range];
    return attrString;
}
@end
